<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      </el-form-item>


      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="memberList" @selection-change="handleSelectionChange">
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="工作单位" align="center" prop="unit" />
      <el-table-column label="接单总数" align="center" prop="sumorordernum" />
      <el-table-column label="维修工单数" align="center" prop="repairordernum" />
      <el-table-column label="保养工单数" align="center" prop="takecareordernum" />
      <el-table-column label="检定工单数" align="center" prop="checkordernum" />
      <el-table-column label="运营工单数" align="center" prop="operateordernum" />
      <el-table-column label="总工时数" align="center" prop="totaltime" />
      <el-table-column label="平均维修工时" align="center" prop="averepairtime" />
      <el-table-column label="平均维修工单费用" align="center" prop="averepaircost" />
      <el-table-column label="平均运营相关费用" align="center" prop="averoperatecost" />
      <el-table-column label="办公费用" align="center" prop="officecost" />
      <el-table-column label="配件工具费用" align="center" prop="toolcost" />
      <el-table-column label="交通费用" align="center" prop="trafficcost" />
      <el-table-column label="住宿费用" align="center" prop="staycost" />
      <el-table-column label="接待费用" align="center" prop="receivecost" />
      <el-table-column label="其他费用" align="center" prop="othercost" />
      

    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>
import { zyxMemberCreditlist, getMember, delMember, addMember, updateMember, exportMember } from "@/api/zyx/member";
import FileUpload from '@/components/FileUpload';
import { treeselect as deviceTreeselect,  } from "@/api/zyx/device";
import { listTreeData,  } from "@/api/system/dept";


export default {
  name: "Member",
  components: {
    FileUpload,
  },
  data() {
    return {
      props: {
        label: 'label',
        children: 'zones',
        isLeaf: 'leaf'
      },

      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      checkedIds:[],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 成员基础信表格数据
      memberList: [],
      expandedKeys:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 学历字典
      educationOptions: [],
      // 负责科室字典
      dutyofficesOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        unit: null,
        education: null,
        major: null,
        dutyoffices: null,
        dutydevice: null,
        mobile: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
          { required: true, message: "姓名不能为空", trigger: "blur" },

        ],
        mobile: [
          { required: true, message: "联系方式不能为空", trigger: "blur" },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ],

      },

      // 设备列表
      deviceOptions: [],
    };
  },
  created() {
    this.getList();
    this.getDicts("zyx_education").then(response => {
      this.educationOptions = response.data;
    });
    this.getDicts("zyx_dutyoffices").then(response => {
      this.dutyofficesOptions = response.data;
    });
  },
  methods: {

    /** 查询成员基础信列表 */
    getList() {
      this.loading = true;
      zyxMemberCreditlist(this.queryParams).then(response => {
        this.memberList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 学历字典翻译
    educationFormat(row, column) {
      return this.selectDictLabel(this.educationOptions, row.education);
    },
    // 负责科室字典翻译
    dutyofficesFormat(row, column) {
      return this.selectDictLabel(this.dutyofficesOptions, row.dutyoffices);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        departid: null,
        name: null,
        age: null,
        unit: null,
        education: null,
        major: null,
        position: null,
        dutyoffices: null,
        dutydevice: null,
        dutydevices:null,
        mobile: null,
        appendix: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        delFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加成员基础信";
    },

    handleSrch(memberid){
      this.$refs.memberDeviceSrchListRef.memid=memberid
       this.$refs.memberDeviceSrchListRef.getList();
      this.$refs.memberDeviceSrchListRef.visible = true;
    },
    handleShowAdd(memberid){
       this.$refs.selectDeviceListRef.memberid=memberid
       this.$refs.selectDeviceListRef.visible = true;
    },
    handleHideAdd(){
       this.$refs.selectDeviceListRef.visible = false;
    }
  }
};
</script>
